//|||||||||||||||||||||||||||||||||||||||||||||||

#ifndef GAME_STATE_HPP
#define GAME_STATE_HPP

//|||||||||||||||||||||||||||||||||||||||||||||||

#include "AppState.hpp"

#include "DotSceneLoader.hpp"
#include <OgreSubEntity.h>
#include <OgreMaterialManager.h>
#include "BasePlayer.h"
#include "BaseWall.h"
#include "DefaultCube.h"

#include "BtOgrePG.h"
#include "BtOgreGP.h"
#include "BtOgreExtras.h"
//|||||||||||||||||||||||||||||||||||||||||||||||

enum QueryFlags
{

	 PLAYER_CHARACTER = 1<<0,
     ENEMY_CHARACTERS = 1<<1,
     STATIONARY_OBJECTS = 1<<2
};

//|||||||||||||||||||||||||||||||||||||||||||||||

class GameState : public AppState
{
public:
	GameState();
	~GameState(void);

	DECLARE_APPSTATE_CLASS(GameState)

	void enter();
	void createScene();
	void exit();
	bool pause();
	void resume();

	void moveCamera();
	void getInput();
    void buildGUI();

	bool keyPressed(const OIS::KeyEvent &keyEventRef);
	bool keyReleased(const OIS::KeyEvent &keyEventRef);

	bool mouseMoved(const OIS::MouseEvent &arg);
	bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
	bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);

	void onLeftPressed(const OIS::MouseEvent &evt);
    void itemSelected(OgreBites::SelectMenu* menu);
	void createGrid(int numcols, int numrows, float spacing, float size);
	void update(double timeSinceLastFrame);
	
	btRigidBody *mGroundBody;

private:
	Ogre::SceneNode*			m_pFloorNode;
	Ogre::Entity*				m_pFloorEntity;
	DefaultRectangle*			m_pFloorRectangle;

    OgreBites::ParamsPanel*		m_pDetailsPanel;
	bool						m_bQuit;

	Ogre::RaySceneQuery*		m_pRSQ;
	Ogre::SceneNode*			m_pCurrentObject;
	Ogre::Entity*				m_pCurrentEntity;
	bool						m_bLMouseDown, m_bRMouseDown;
	bool						m_bSettingsMode;
	Ogre::Plane					m_TargetPlane;
	std::vector<BasePlayer*>	m_Players;
	std::vector<BaseWall*>		m_Walls;

    BtOgre::DebugDrawer *dbgdraw;

   //PHYSICS
   //btAxisSweep3 *mBroadphase;
   //btDefaultCollisionConfiguration *mCollisionConfig;
  // btCollisionDispatcher *mDispatcher;
   //btSequentialImpulseConstraintSolver *mSolver;

  // btDefaultMotionState* groundState;
	//btCollisionShape *mGroundShape;

};

//|||||||||||||||||||||||||||||||||||||||||||||||

#endif

//|||||||||||||||||||||||||||||||||||||||||||||||